var WarehouseInfo = function () {
  var template = /* html */ `
    <div class="warehouse-info" v-loading.fullscreen.lock="loading">
      <div v-if="detail!==null">
        <el-form label-width="140px">
          <el-form-item label="物料名称">
            <span>{{detail.materialName}}</span>
          </el-form-item>
          <el-form-item label="规格">
            <span>{{detail.model}}</span>
          </el-form-item>
          <el-form-item label="编号">
            <span>{{detail.color}}</span>
          </el-form-item>
          <el-form-item label="供应商">
            <span>{{detail.providerName}}</span>
          </el-form-item>
          <el-form-item label="默认仓库">
            <span>{{warehouse.defaultWarehouse}}</span>
          </el-form-item>
          <el-form-item label="物料单位合格数">
            <span>{{detail.count}}{{detail.unit}}</span>
          </el-form-item>
          <el-form-item label="物料单位不合格数">
            <span>{{detail.noCount}}{{detail.unit}}</span>
          </el-form-item>
          <el-form-item label="生产单位合格数" v-if="detail.productionUnitCount!==null">
            <span>{{detail.productionUnitCount}}</span>
          </el-form-item>
          <el-form-item label="生产单位不合格数" v-if="detail.productionUnitNoCount!==null">
            <span>{{detail.productionUnitNoCount}}</span>
          </el-form-item>
        </el-form>
      </div>
    </div>
  `;

  return {
    props: {
      warehouse: {
        type: Object,
        required: true
      }
    },

    data: function () {
      return {
        loading: false,
        detail: null
      };
    },

    created: function () {
      this.setDetail();
    },

    methods: {
      setDetail: function () {
        var warehouse = this.warehouse;
        var warehouseType = warehouse.warehouseType;
        var postData = {
          warehouseType: warehouseType,
          materialCode: warehouse.materialCode
        };

        this.loading = true;
        var self = this;
        ajaxRequest("companyMaterialCount/getCompanyMaterialStackByWarehouseInOut", postData).then(function (detailList) {
          self.loading = false;
          var detail = detailList[0];
          if (detail === undefined) {
            detail = null;
          }
          self.detail = detail;
        }).catch(function () {
          self.loading = false;
        });
      }
    },

    template: template
  };
}();
